// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Aggregations;

public sealed partial class SignificantTextAggregation
{
	/// <summary>
	/// <para>
	/// A background filter that can be used to focus in on significant terms within a narrower context, instead of the entire index.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("background_filter")]
	public Elastic.Clients.Elasticsearch.QueryDsl.Query? BackgroundFilter { get; set; }

	/// <summary>
	/// <para>
	/// Use Chi square, as described in "Information Retrieval", Manning et al., Chapter 13.5.2, as the significance score.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("chi_square")]
	public Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristic? ChiSquare { get; set; }

	/// <summary>
	/// <para>
	/// Values to exclude.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("exclude")]
	public Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? Exclude { get; set; }

	/// <summary>
	/// <para>
	/// Determines whether the aggregation will use field values directly or global ordinals.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("execution_hint")]
	public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; }

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("field")]
	public Elastic.Clients.Elasticsearch.Field? Field { get; set; }

	/// <summary>
	/// <para>
	/// Whether to out duplicate text to deal with noisy data.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("filter_duplicate_text")]
	public bool? FilterDuplicateText { get; set; }

	/// <summary>
	/// <para>
	/// Use Google normalized distance as described in "The Google Similarity Distance", Cilibrasi and Vitanyi, 2007, as the significance score.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("gnd")]
	public Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristic? Gnd { get; set; }

	/// <summary>
	/// <para>
	/// Values to include.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("include")]
	public Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? Include { get; set; }

	/// <summary>
	/// <para>
	/// Use JLH score as the significance score.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("jlh")]
	public Elastic.Clients.Elasticsearch.EmptyObject? Jlh { get; set; }

	/// <summary>
	/// <para>
	/// Only return values that are found in more than <c>min_doc_count</c> hits.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("min_doc_count")]
	public long? MinDocCount { get; set; }

	/// <summary>
	/// <para>
	/// Use mutual information as described in "Information Retrieval", Manning et al., Chapter 13.5.1, as the significance score.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("mutual_information")]
	public Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristic? MutualInformation { get; set; }

	/// <summary>
	/// <para>
	/// A simple calculation of the number of documents in the foreground sample with a term divided by the number of documents in the background with the term.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("percentage")]
	public Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristic? Percentage { get; set; }

	/// <summary>
	/// <para>
	/// Customized score, implemented via a script.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("script_heuristic")]
	public Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? ScriptHeuristic { get; set; }

	/// <summary>
	/// <para>
	/// Regulates the certainty a shard has if the values should actually be added to the candidate list or not with respect to the min_doc_count.
	/// Values will only be considered if their local shard frequency within the set is higher than the <c>shard_min_doc_count</c>.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("shard_min_doc_count")]
	public long? ShardMinDocCount { get; set; }

	/// <summary>
	/// <para>
	/// The number of candidate terms produced by each shard.
	/// By default, <c>shard_size</c> will be automatically estimated based on the number of shards and the <c>size</c> parameter.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("shard_size")]
	public int? ShardSize { get; set; }

	/// <summary>
	/// <para>
	/// The number of buckets returned out of the overall terms list.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("size")]
	public int? Size { get; set; }

	/// <summary>
	/// <para>
	/// Overrides the JSON <c>_source</c> fields from which text will be analyzed.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("source_fields")]
	[JsonConverter(typeof(SingleOrManyFieldsConverter))]
	public Elastic.Clients.Elasticsearch.Fields? SourceFields { get; set; }

	public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(SignificantTextAggregation significantTextAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.SignificantText(significantTextAggregation);
}

public sealed partial class SignificantTextAggregationDescriptor<TDocument> : SerializableDescriptor<SignificantTextAggregationDescriptor<TDocument>>
{
	internal SignificantTextAggregationDescriptor(Action<SignificantTextAggregationDescriptor<TDocument>> configure) => configure.Invoke(this);

	public SignificantTextAggregationDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.QueryDsl.Query? BackgroundFilterValue { get; set; }
	private Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument> BackgroundFilterDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument>> BackgroundFilterDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristic? ChiSquareValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor ChiSquareDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor> ChiSquareDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? ExcludeValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? ExecutionHintValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; }
	private bool? FilterDuplicateTextValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristic? GndValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor GndDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor> GndDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? IncludeValue { get; set; }
	private Elastic.Clients.Elasticsearch.EmptyObject? JlhValue { get; set; }
	private Elastic.Clients.Elasticsearch.EmptyObjectDescriptor JlhDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.EmptyObjectDescriptor> JlhDescriptorAction { get; set; }
	private long? MinDocCountValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristic? MutualInformationValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor MutualInformationDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor> MutualInformationDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristic? PercentageValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor PercentageDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor> PercentageDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? ScriptHeuristicValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor ScriptHeuristicDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor> ScriptHeuristicDescriptorAction { get; set; }
	private long? ShardMinDocCountValue { get; set; }
	private int? ShardSizeValue { get; set; }
	private int? SizeValue { get; set; }
	private Elastic.Clients.Elasticsearch.Fields? SourceFieldsValue { get; set; }

	/// <summary>
	/// <para>
	/// A background filter that can be used to focus in on significant terms within a narrower context, instead of the entire index.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> BackgroundFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? backgroundFilter)
	{
		BackgroundFilterDescriptor = null;
		BackgroundFilterDescriptorAction = null;
		BackgroundFilterValue = backgroundFilter;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> BackgroundFilter(Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument> descriptor)
	{
		BackgroundFilterValue = null;
		BackgroundFilterDescriptorAction = null;
		BackgroundFilterDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> BackgroundFilter(Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument>> configure)
	{
		BackgroundFilterValue = null;
		BackgroundFilterDescriptor = null;
		BackgroundFilterDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use Chi square, as described in "Information Retrieval", Manning et al., Chapter 13.5.2, as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> ChiSquare(Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristic? chiSquare)
	{
		ChiSquareDescriptor = null;
		ChiSquareDescriptorAction = null;
		ChiSquareValue = chiSquare;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> ChiSquare(Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor descriptor)
	{
		ChiSquareValue = null;
		ChiSquareDescriptorAction = null;
		ChiSquareDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> ChiSquare(Action<Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor> configure)
	{
		ChiSquareValue = null;
		ChiSquareDescriptor = null;
		ChiSquareDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Values to exclude.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Exclude(Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? exclude)
	{
		ExcludeValue = exclude;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Determines whether the aggregation will use field values directly or global ordinals.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> ExecutionHint(Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? executionHint)
	{
		ExecutionHintValue = executionHint;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field? field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Field(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Whether to out duplicate text to deal with noisy data.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> FilterDuplicateText(bool? filterDuplicateText = true)
	{
		FilterDuplicateTextValue = filterDuplicateText;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use Google normalized distance as described in "The Google Similarity Distance", Cilibrasi and Vitanyi, 2007, as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Gnd(Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristic? gnd)
	{
		GndDescriptor = null;
		GndDescriptorAction = null;
		GndValue = gnd;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> Gnd(Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor descriptor)
	{
		GndValue = null;
		GndDescriptorAction = null;
		GndDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> Gnd(Action<Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor> configure)
	{
		GndValue = null;
		GndDescriptor = null;
		GndDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Values to include.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Include(Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? include)
	{
		IncludeValue = include;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use JLH score as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Jlh(Elastic.Clients.Elasticsearch.EmptyObject? jlh)
	{
		JlhDescriptor = null;
		JlhDescriptorAction = null;
		JlhValue = jlh;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> Jlh(Elastic.Clients.Elasticsearch.EmptyObjectDescriptor descriptor)
	{
		JlhValue = null;
		JlhDescriptorAction = null;
		JlhDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> Jlh(Action<Elastic.Clients.Elasticsearch.EmptyObjectDescriptor> configure)
	{
		JlhValue = null;
		JlhDescriptor = null;
		JlhDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Only return values that are found in more than <c>min_doc_count</c> hits.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> MinDocCount(long? minDocCount)
	{
		MinDocCountValue = minDocCount;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use mutual information as described in "Information Retrieval", Manning et al., Chapter 13.5.1, as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> MutualInformation(Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristic? mutualInformation)
	{
		MutualInformationDescriptor = null;
		MutualInformationDescriptorAction = null;
		MutualInformationValue = mutualInformation;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> MutualInformation(Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor descriptor)
	{
		MutualInformationValue = null;
		MutualInformationDescriptorAction = null;
		MutualInformationDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> MutualInformation(Action<Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor> configure)
	{
		MutualInformationValue = null;
		MutualInformationDescriptor = null;
		MutualInformationDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A simple calculation of the number of documents in the foreground sample with a term divided by the number of documents in the background with the term.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Percentage(Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristic? percentage)
	{
		PercentageDescriptor = null;
		PercentageDescriptorAction = null;
		PercentageValue = percentage;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> Percentage(Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor descriptor)
	{
		PercentageValue = null;
		PercentageDescriptorAction = null;
		PercentageDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> Percentage(Action<Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor> configure)
	{
		PercentageValue = null;
		PercentageDescriptor = null;
		PercentageDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Customized score, implemented via a script.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> ScriptHeuristic(Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? scriptHeuristic)
	{
		ScriptHeuristicDescriptor = null;
		ScriptHeuristicDescriptorAction = null;
		ScriptHeuristicValue = scriptHeuristic;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> ScriptHeuristic(Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor descriptor)
	{
		ScriptHeuristicValue = null;
		ScriptHeuristicDescriptorAction = null;
		ScriptHeuristicDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor<TDocument> ScriptHeuristic(Action<Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor> configure)
	{
		ScriptHeuristicValue = null;
		ScriptHeuristicDescriptor = null;
		ScriptHeuristicDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Regulates the certainty a shard has if the values should actually be added to the candidate list or not with respect to the min_doc_count.
	/// Values will only be considered if their local shard frequency within the set is higher than the <c>shard_min_doc_count</c>.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> ShardMinDocCount(long? shardMinDocCount)
	{
		ShardMinDocCountValue = shardMinDocCount;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The number of candidate terms produced by each shard.
	/// By default, <c>shard_size</c> will be automatically estimated based on the number of shards and the <c>size</c> parameter.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> ShardSize(int? shardSize)
	{
		ShardSizeValue = shardSize;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The number of buckets returned out of the overall terms list.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> Size(int? size)
	{
		SizeValue = size;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Overrides the JSON <c>_source</c> fields from which text will be analyzed.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor<TDocument> SourceFields(Elastic.Clients.Elasticsearch.Fields? sourceFields)
	{
		SourceFieldsValue = sourceFields;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (BackgroundFilterDescriptor is not null)
		{
			writer.WritePropertyName("background_filter");
			JsonSerializer.Serialize(writer, BackgroundFilterDescriptor, options);
		}
		else if (BackgroundFilterDescriptorAction is not null)
		{
			writer.WritePropertyName("background_filter");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument>(BackgroundFilterDescriptorAction), options);
		}
		else if (BackgroundFilterValue is not null)
		{
			writer.WritePropertyName("background_filter");
			JsonSerializer.Serialize(writer, BackgroundFilterValue, options);
		}

		if (ChiSquareDescriptor is not null)
		{
			writer.WritePropertyName("chi_square");
			JsonSerializer.Serialize(writer, ChiSquareDescriptor, options);
		}
		else if (ChiSquareDescriptorAction is not null)
		{
			writer.WritePropertyName("chi_square");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor(ChiSquareDescriptorAction), options);
		}
		else if (ChiSquareValue is not null)
		{
			writer.WritePropertyName("chi_square");
			JsonSerializer.Serialize(writer, ChiSquareValue, options);
		}

		if (ExcludeValue is not null)
		{
			writer.WritePropertyName("exclude");
			JsonSerializer.Serialize(writer, ExcludeValue, options);
		}

		if (ExecutionHintValue is not null)
		{
			writer.WritePropertyName("execution_hint");
			JsonSerializer.Serialize(writer, ExecutionHintValue, options);
		}

		if (FieldValue is not null)
		{
			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
		}

		if (FilterDuplicateTextValue.HasValue)
		{
			writer.WritePropertyName("filter_duplicate_text");
			writer.WriteBooleanValue(FilterDuplicateTextValue.Value);
		}

		if (GndDescriptor is not null)
		{
			writer.WritePropertyName("gnd");
			JsonSerializer.Serialize(writer, GndDescriptor, options);
		}
		else if (GndDescriptorAction is not null)
		{
			writer.WritePropertyName("gnd");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor(GndDescriptorAction), options);
		}
		else if (GndValue is not null)
		{
			writer.WritePropertyName("gnd");
			JsonSerializer.Serialize(writer, GndValue, options);
		}

		if (IncludeValue is not null)
		{
			writer.WritePropertyName("include");
			JsonSerializer.Serialize(writer, IncludeValue, options);
		}

		if (JlhDescriptor is not null)
		{
			writer.WritePropertyName("jlh");
			JsonSerializer.Serialize(writer, JlhDescriptor, options);
		}
		else if (JlhDescriptorAction is not null)
		{
			writer.WritePropertyName("jlh");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.EmptyObjectDescriptor(JlhDescriptorAction), options);
		}
		else if (JlhValue is not null)
		{
			writer.WritePropertyName("jlh");
			JsonSerializer.Serialize(writer, JlhValue, options);
		}

		if (MinDocCountValue.HasValue)
		{
			writer.WritePropertyName("min_doc_count");
			writer.WriteNumberValue(MinDocCountValue.Value);
		}

		if (MutualInformationDescriptor is not null)
		{
			writer.WritePropertyName("mutual_information");
			JsonSerializer.Serialize(writer, MutualInformationDescriptor, options);
		}
		else if (MutualInformationDescriptorAction is not null)
		{
			writer.WritePropertyName("mutual_information");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor(MutualInformationDescriptorAction), options);
		}
		else if (MutualInformationValue is not null)
		{
			writer.WritePropertyName("mutual_information");
			JsonSerializer.Serialize(writer, MutualInformationValue, options);
		}

		if (PercentageDescriptor is not null)
		{
			writer.WritePropertyName("percentage");
			JsonSerializer.Serialize(writer, PercentageDescriptor, options);
		}
		else if (PercentageDescriptorAction is not null)
		{
			writer.WritePropertyName("percentage");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor(PercentageDescriptorAction), options);
		}
		else if (PercentageValue is not null)
		{
			writer.WritePropertyName("percentage");
			JsonSerializer.Serialize(writer, PercentageValue, options);
		}

		if (ScriptHeuristicDescriptor is not null)
		{
			writer.WritePropertyName("script_heuristic");
			JsonSerializer.Serialize(writer, ScriptHeuristicDescriptor, options);
		}
		else if (ScriptHeuristicDescriptorAction is not null)
		{
			writer.WritePropertyName("script_heuristic");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor(ScriptHeuristicDescriptorAction), options);
		}
		else if (ScriptHeuristicValue is not null)
		{
			writer.WritePropertyName("script_heuristic");
			JsonSerializer.Serialize(writer, ScriptHeuristicValue, options);
		}

		if (ShardMinDocCountValue.HasValue)
		{
			writer.WritePropertyName("shard_min_doc_count");
			writer.WriteNumberValue(ShardMinDocCountValue.Value);
		}

		if (ShardSizeValue.HasValue)
		{
			writer.WritePropertyName("shard_size");
			writer.WriteNumberValue(ShardSizeValue.Value);
		}

		if (SizeValue.HasValue)
		{
			writer.WritePropertyName("size");
			writer.WriteNumberValue(SizeValue.Value);
		}

		if (SourceFieldsValue is not null)
		{
			writer.WritePropertyName("source_fields");
			JsonSerializer.Serialize(writer, SourceFieldsValue, options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class SignificantTextAggregationDescriptor : SerializableDescriptor<SignificantTextAggregationDescriptor>
{
	internal SignificantTextAggregationDescriptor(Action<SignificantTextAggregationDescriptor> configure) => configure.Invoke(this);

	public SignificantTextAggregationDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.QueryDsl.Query? BackgroundFilterValue { get; set; }
	private Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor BackgroundFilterDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor> BackgroundFilterDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristic? ChiSquareValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor ChiSquareDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor> ChiSquareDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? ExcludeValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? ExecutionHintValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; }
	private bool? FilterDuplicateTextValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristic? GndValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor GndDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor> GndDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? IncludeValue { get; set; }
	private Elastic.Clients.Elasticsearch.EmptyObject? JlhValue { get; set; }
	private Elastic.Clients.Elasticsearch.EmptyObjectDescriptor JlhDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.EmptyObjectDescriptor> JlhDescriptorAction { get; set; }
	private long? MinDocCountValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristic? MutualInformationValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor MutualInformationDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor> MutualInformationDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristic? PercentageValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor PercentageDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor> PercentageDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? ScriptHeuristicValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor ScriptHeuristicDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor> ScriptHeuristicDescriptorAction { get; set; }
	private long? ShardMinDocCountValue { get; set; }
	private int? ShardSizeValue { get; set; }
	private int? SizeValue { get; set; }
	private Elastic.Clients.Elasticsearch.Fields? SourceFieldsValue { get; set; }

	/// <summary>
	/// <para>
	/// A background filter that can be used to focus in on significant terms within a narrower context, instead of the entire index.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor BackgroundFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? backgroundFilter)
	{
		BackgroundFilterDescriptor = null;
		BackgroundFilterDescriptorAction = null;
		BackgroundFilterValue = backgroundFilter;
		return Self;
	}

	public SignificantTextAggregationDescriptor BackgroundFilter(Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor descriptor)
	{
		BackgroundFilterValue = null;
		BackgroundFilterDescriptorAction = null;
		BackgroundFilterDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor BackgroundFilter(Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor> configure)
	{
		BackgroundFilterValue = null;
		BackgroundFilterDescriptor = null;
		BackgroundFilterDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use Chi square, as described in "Information Retrieval", Manning et al., Chapter 13.5.2, as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor ChiSquare(Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristic? chiSquare)
	{
		ChiSquareDescriptor = null;
		ChiSquareDescriptorAction = null;
		ChiSquareValue = chiSquare;
		return Self;
	}

	public SignificantTextAggregationDescriptor ChiSquare(Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor descriptor)
	{
		ChiSquareValue = null;
		ChiSquareDescriptorAction = null;
		ChiSquareDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor ChiSquare(Action<Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor> configure)
	{
		ChiSquareValue = null;
		ChiSquareDescriptor = null;
		ChiSquareDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Values to exclude.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Exclude(Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? exclude)
	{
		ExcludeValue = exclude;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Determines whether the aggregation will use field values directly or global ordinals.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor ExecutionHint(Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? executionHint)
	{
		ExecutionHintValue = executionHint;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field from which to return significant text.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Whether to out duplicate text to deal with noisy data.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor FilterDuplicateText(bool? filterDuplicateText = true)
	{
		FilterDuplicateTextValue = filterDuplicateText;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use Google normalized distance as described in "The Google Similarity Distance", Cilibrasi and Vitanyi, 2007, as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Gnd(Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristic? gnd)
	{
		GndDescriptor = null;
		GndDescriptorAction = null;
		GndValue = gnd;
		return Self;
	}

	public SignificantTextAggregationDescriptor Gnd(Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor descriptor)
	{
		GndValue = null;
		GndDescriptorAction = null;
		GndDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor Gnd(Action<Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor> configure)
	{
		GndValue = null;
		GndDescriptor = null;
		GndDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Values to include.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Include(Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? include)
	{
		IncludeValue = include;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use JLH score as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Jlh(Elastic.Clients.Elasticsearch.EmptyObject? jlh)
	{
		JlhDescriptor = null;
		JlhDescriptorAction = null;
		JlhValue = jlh;
		return Self;
	}

	public SignificantTextAggregationDescriptor Jlh(Elastic.Clients.Elasticsearch.EmptyObjectDescriptor descriptor)
	{
		JlhValue = null;
		JlhDescriptorAction = null;
		JlhDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor Jlh(Action<Elastic.Clients.Elasticsearch.EmptyObjectDescriptor> configure)
	{
		JlhValue = null;
		JlhDescriptor = null;
		JlhDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Only return values that are found in more than <c>min_doc_count</c> hits.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor MinDocCount(long? minDocCount)
	{
		MinDocCountValue = minDocCount;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Use mutual information as described in "Information Retrieval", Manning et al., Chapter 13.5.1, as the significance score.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor MutualInformation(Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristic? mutualInformation)
	{
		MutualInformationDescriptor = null;
		MutualInformationDescriptorAction = null;
		MutualInformationValue = mutualInformation;
		return Self;
	}

	public SignificantTextAggregationDescriptor MutualInformation(Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor descriptor)
	{
		MutualInformationValue = null;
		MutualInformationDescriptorAction = null;
		MutualInformationDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor MutualInformation(Action<Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor> configure)
	{
		MutualInformationValue = null;
		MutualInformationDescriptor = null;
		MutualInformationDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A simple calculation of the number of documents in the foreground sample with a term divided by the number of documents in the background with the term.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Percentage(Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristic? percentage)
	{
		PercentageDescriptor = null;
		PercentageDescriptorAction = null;
		PercentageValue = percentage;
		return Self;
	}

	public SignificantTextAggregationDescriptor Percentage(Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor descriptor)
	{
		PercentageValue = null;
		PercentageDescriptorAction = null;
		PercentageDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor Percentage(Action<Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor> configure)
	{
		PercentageValue = null;
		PercentageDescriptor = null;
		PercentageDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Customized score, implemented via a script.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor ScriptHeuristic(Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? scriptHeuristic)
	{
		ScriptHeuristicDescriptor = null;
		ScriptHeuristicDescriptorAction = null;
		ScriptHeuristicValue = scriptHeuristic;
		return Self;
	}

	public SignificantTextAggregationDescriptor ScriptHeuristic(Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor descriptor)
	{
		ScriptHeuristicValue = null;
		ScriptHeuristicDescriptorAction = null;
		ScriptHeuristicDescriptor = descriptor;
		return Self;
	}

	public SignificantTextAggregationDescriptor ScriptHeuristic(Action<Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor> configure)
	{
		ScriptHeuristicValue = null;
		ScriptHeuristicDescriptor = null;
		ScriptHeuristicDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Regulates the certainty a shard has if the values should actually be added to the candidate list or not with respect to the min_doc_count.
	/// Values will only be considered if their local shard frequency within the set is higher than the <c>shard_min_doc_count</c>.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor ShardMinDocCount(long? shardMinDocCount)
	{
		ShardMinDocCountValue = shardMinDocCount;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The number of candidate terms produced by each shard.
	/// By default, <c>shard_size</c> will be automatically estimated based on the number of shards and the <c>size</c> parameter.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor ShardSize(int? shardSize)
	{
		ShardSizeValue = shardSize;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The number of buckets returned out of the overall terms list.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor Size(int? size)
	{
		SizeValue = size;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Overrides the JSON <c>_source</c> fields from which text will be analyzed.
	/// </para>
	/// </summary>
	public SignificantTextAggregationDescriptor SourceFields(Elastic.Clients.Elasticsearch.Fields? sourceFields)
	{
		SourceFieldsValue = sourceFields;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (BackgroundFilterDescriptor is not null)
		{
			writer.WritePropertyName("background_filter");
			JsonSerializer.Serialize(writer, BackgroundFilterDescriptor, options);
		}
		else if (BackgroundFilterDescriptorAction is not null)
		{
			writer.WritePropertyName("background_filter");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor(BackgroundFilterDescriptorAction), options);
		}
		else if (BackgroundFilterValue is not null)
		{
			writer.WritePropertyName("background_filter");
			JsonSerializer.Serialize(writer, BackgroundFilterValue, options);
		}

		if (ChiSquareDescriptor is not null)
		{
			writer.WritePropertyName("chi_square");
			JsonSerializer.Serialize(writer, ChiSquareDescriptor, options);
		}
		else if (ChiSquareDescriptorAction is not null)
		{
			writer.WritePropertyName("chi_square");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristicDescriptor(ChiSquareDescriptorAction), options);
		}
		else if (ChiSquareValue is not null)
		{
			writer.WritePropertyName("chi_square");
			JsonSerializer.Serialize(writer, ChiSquareValue, options);
		}

		if (ExcludeValue is not null)
		{
			writer.WritePropertyName("exclude");
			JsonSerializer.Serialize(writer, ExcludeValue, options);
		}

		if (ExecutionHintValue is not null)
		{
			writer.WritePropertyName("execution_hint");
			JsonSerializer.Serialize(writer, ExecutionHintValue, options);
		}

		if (FieldValue is not null)
		{
			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
		}

		if (FilterDuplicateTextValue.HasValue)
		{
			writer.WritePropertyName("filter_duplicate_text");
			writer.WriteBooleanValue(FilterDuplicateTextValue.Value);
		}

		if (GndDescriptor is not null)
		{
			writer.WritePropertyName("gnd");
			JsonSerializer.Serialize(writer, GndDescriptor, options);
		}
		else if (GndDescriptorAction is not null)
		{
			writer.WritePropertyName("gnd");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristicDescriptor(GndDescriptorAction), options);
		}
		else if (GndValue is not null)
		{
			writer.WritePropertyName("gnd");
			JsonSerializer.Serialize(writer, GndValue, options);
		}

		if (IncludeValue is not null)
		{
			writer.WritePropertyName("include");
			JsonSerializer.Serialize(writer, IncludeValue, options);
		}

		if (JlhDescriptor is not null)
		{
			writer.WritePropertyName("jlh");
			JsonSerializer.Serialize(writer, JlhDescriptor, options);
		}
		else if (JlhDescriptorAction is not null)
		{
			writer.WritePropertyName("jlh");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.EmptyObjectDescriptor(JlhDescriptorAction), options);
		}
		else if (JlhValue is not null)
		{
			writer.WritePropertyName("jlh");
			JsonSerializer.Serialize(writer, JlhValue, options);
		}

		if (MinDocCountValue.HasValue)
		{
			writer.WritePropertyName("min_doc_count");
			writer.WriteNumberValue(MinDocCountValue.Value);
		}

		if (MutualInformationDescriptor is not null)
		{
			writer.WritePropertyName("mutual_information");
			JsonSerializer.Serialize(writer, MutualInformationDescriptor, options);
		}
		else if (MutualInformationDescriptorAction is not null)
		{
			writer.WritePropertyName("mutual_information");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristicDescriptor(MutualInformationDescriptorAction), options);
		}
		else if (MutualInformationValue is not null)
		{
			writer.WritePropertyName("mutual_information");
			JsonSerializer.Serialize(writer, MutualInformationValue, options);
		}

		if (PercentageDescriptor is not null)
		{
			writer.WritePropertyName("percentage");
			JsonSerializer.Serialize(writer, PercentageDescriptor, options);
		}
		else if (PercentageDescriptorAction is not null)
		{
			writer.WritePropertyName("percentage");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristicDescriptor(PercentageDescriptorAction), options);
		}
		else if (PercentageValue is not null)
		{
			writer.WritePropertyName("percentage");
			JsonSerializer.Serialize(writer, PercentageValue, options);
		}

		if (ScriptHeuristicDescriptor is not null)
		{
			writer.WritePropertyName("script_heuristic");
			JsonSerializer.Serialize(writer, ScriptHeuristicDescriptor, options);
		}
		else if (ScriptHeuristicDescriptorAction is not null)
		{
			writer.WritePropertyName("script_heuristic");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristicDescriptor(ScriptHeuristicDescriptorAction), options);
		}
		else if (ScriptHeuristicValue is not null)
		{
			writer.WritePropertyName("script_heuristic");
			JsonSerializer.Serialize(writer, ScriptHeuristicValue, options);
		}

		if (ShardMinDocCountValue.HasValue)
		{
			writer.WritePropertyName("shard_min_doc_count");
			writer.WriteNumberValue(ShardMinDocCountValue.Value);
		}

		if (ShardSizeValue.HasValue)
		{
			writer.WritePropertyName("shard_size");
			writer.WriteNumberValue(ShardSizeValue.Value);
		}

		if (SizeValue.HasValue)
		{
			writer.WritePropertyName("size");
			writer.WriteNumberValue(SizeValue.Value);
		}

		if (SourceFieldsValue is not null)
		{
			writer.WritePropertyName("source_fields");
			JsonSerializer.Serialize(writer, SourceFieldsValue, options);
		}

		writer.WriteEndObject();
	}
}